package com.hzcx.app.simplechat.ui.home.presenter;

import android.content.Context;

import com.hzcx.app.simplechat.api.BaseDialogObserver;
import com.hzcx.app.simplechat.base.BaseEmptyBean;
import com.hzcx.app.simplechat.base.BasePresenter;
import com.hzcx.app.simplechat.model.FriendModel;
import com.hzcx.app.simplechat.model.HomeModel;
import com.hzcx.app.simplechat.model.UserModel;
import com.hzcx.app.simplechat.ui.home.bean.AddFriendSearchBean;
import com.hzcx.app.simplechat.ui.home.contract.AddFriendContract;
import com.hzcx.app.simplechat.ui.home.contract.AddFriendSearchContract;
import com.hzcx.app.simplechat.ui.user.bean.UserInfoBean;

public class AddFriendPresenter extends BasePresenter<AddFriendContract.View> implements AddFriendContract.Presenter {


    /**
     *  获取用户信息
     * @param context
     * @param id
     */
    @Override
    public void getUserInfo(Context context, int id) {
        UserModel.getUserInfo(context, id, new BaseDialogObserver<UserInfoBean>(context) {
            @Override
            protected void onSuccess(UserInfoBean data) {
                try {
                    mView.userInfoResult(data);
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     *  发送添加好友请求
     * @param context
     * @param member_id
     * @param ver_request
     */
    @Override
    public void sendAddFriendRequest(Context context, int member_id, String ver_request,int type) {
        FriendModel.sendAddFriendRequest(context, member_id, ver_request,type, new BaseDialogObserver<BaseEmptyBean>(context) {
            @Override
            protected void onSuccess(BaseEmptyBean data) {
                mView.sendSuccess();
            }
        });
    }
}
